package com.hopu.petshop.controller.old;//package com.hopu.petshop.controller;
//
//import com.hopu.petshop.entity.Pet;
//import com.hopu.petshop.service.PetService;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.sql.SQLException;
//
///**
// * 查询宠物名是否存在Servlet
// */
//@WebServlet("/findPetByName.do")
//public class FindPetByNameServlet extends HttpServlet {
//
//    //用spring创建service对象
//    private PetService petService = SpringConfig.getContext().getBean(PetService.class);
//
//    @Override
//    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        String name = req.getParameter("name");
//        //调用service查询宠物
//        try {
//            Pet pet = petService.findPetByName(name);
//            //发送宠物是否存在
//            if(pet == null){
//                resp.getWriter().print("ok");
//            }else{
//                resp.getWriter().print("exists");
//            }
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
//    }
//}
